package com.cwj;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class BitSetTest {
    public static void main(String[] args) throws IOException {
//        System.out.println(xorQueries(new int[]{1,3,4,8}, new int[][]{{0,1},{1,2},{0,3},{3,3}}));
//        System.out.println(xorQueries(new int[]{2,3,1,6,7}));
//        System.out.println(xorQueries(new int[]{1,1,1,1,1}));
//        System.out.println(xorQueries(new int[]{2,3}));
//        System.out.println(xorQueries(new int[]{1,3,5,7,9}));
            int i = Integer.parseInt("001001",2);
            i = Integer.lowestOneBit(0b10010);
            i = Integer.lowestOneBit(0b100010);
            i = Integer.highestOneBit(0b100010);
            i = Integer.numberOfLeadingZeros(0b100010);
            i = Integer.numberOfTrailingZeros(0b100010);
        System.out.println(Integer.toBinaryString(1837591841));
        System.out.println(i);
        boolean b1 = true;
        boolean b2 = false;
//        int b3 = b1 ^ b2; // 编译错误 b1 ^ b2的结果是boolean类型
        System.out.println(b1 ^ b2);
//        System.out.println(b1 ^ 2); // 编译错误 Operator '^' cannot be applied to 'boolean', 'int'
//        System.out.println(~b1); // 编译错误 Operator '~' cannot be applied to 'boolean'
        byte bt1 = 3;
        byte bt2 = 2;
//        byte bt3 = bt1 ^ bt2; // 编译错误 bt1 ^ bt2 的结果类型为int
        int bt3 = bt1 ^ bt2;
        System.out.println(bt1 ^ bt2); // 结果：1
        System.out.println(3 ^ bt2); // 结果：1
        byte bt4 = -3;
        System.out.println(bt4 ^ bt2); // 结果：-1
        System.out.println(-3 ^ bt2); // 结果：-1
//        int ibsd = 1 ^ 3L;
        System.out.println(1 ^ 3L);
    }

    public static int xorQueries(int[] arr) {
        int temp = 0;
        for(int i = 0; i < arr.length; i++){
            temp ^= arr[i];
            arr[i] = temp;
        }
        int count = 0;
        for(int i = 0; i < arr.length; i++){
            for(int j = i + 1; j < arr.length; j++){
                if(i==0){
                    if(0 == arr[j]){
                        count += (j-i);
                    }
                }else{
                    if(arr[i-1] == arr[j]){
                        count += (j-i);
                    }
                }
            }
        }
        return count;
    }
}
